<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Title</title>
</head>
<body>
<div id="app">

    <h2 :class="classes">Hello World</h2>

    <button :class="isActive?'active':''" v-on:click="btnClick">我是按钮</button>

    <button :class="{active:isActive}" @click="btnClick">我是按钮</button>

    <button :class="{active:isActive,why:true,kobe:false}" @click="btnClick">我是按钮</button>

    <button class="abc cba" :class="{active:isActive,why:true,kobe:false}" @click="btnClick">我是按钮</button>

    <button class="abc cba" :class="getDynamicClasses()" @click="btnClick">我是按钮</button>

    <h2 v-bind:class="['abc','cba']">Hello Array</h2>
    <h2 :class="['ab',className]">Hello Array</h2>
    <h2 :class="['abc',className,isActive?'active':'']">Hello Array</h2>
    <h2 :class="['abc',className,{active:isActive}]">Hello Array</h2>

</div>
<script src="https://unpkg.com/vue@3"></script>
<script>
    const app=Vue.createApp({
        data(){
            return{
                classes:'abc cba nba',
                isActive:false,
                className:"why"
            }
        },
        methods:{
            btnClick(){
                this.isActive=!this.isActive
            },
            getDynamicClasses(){
                return {active:this.isActive,why:true,kobe:false}
            }
        }
    })
    app.mount("#app")
</script>
</body>
</html>